<style lang="less">
@import "./index.less";
</style>

<template>
  <div>
    <Card dis-hover>
      <Row class="margin-top-10">
        <i-col span="6">
          <span style="font-size:13px"  class="margin-left-10">年份:</span>
          <DatePicker :value="year" size="small" placeholder="年份" type="year" @on-change="setYear"></DatePicker>
        </i-col>
        <i-col span="18">
          <Button class="pull-right margin-right-10" type="primary" icon="android-download" @click="exportCsv">导出</Button>
        </i-col>
      </Row>
      <h2 class="report-title">
        <span>{{year}}年度销售报表</span>
        <span style="font-size:14px">（单位：万元）</span>
      </h2>
      <Table :columns="indexData.tableColumn" :data="tableData" ref="table" stripe></Table>
    </Card>
  </div>
</template>
<script>
import indexData from './index_data.js';
import moment from 'moment';
export default {
  data() {
    return {
      aa:'',
      year:'2018',
      indexData:[],
      tableData: [],
    };
  },
  methods: {
    getReport() {
      this.$http.get('/fi/contracts/'+this.year+'/report').then((res) => {
        this.tableData = res.data.returnValue
      })
    },
    setYear(date) {
      this.year = date
      this.getReport()
    },
    exportCsv() {
      this.$refs.table.exportCsv({
        filename: this.year + '年度销售报表'
      });
    }
  },
  mounted() {
    this.getReport()
  },
  created () {
    this.indexData = indexData
  }
};
</script>

